package com.tongyi.lizhishop.activitys;

import android.net.Uri;
import android.os.Bundle;
import android.support.v4.view.ViewCompat;
import android.text.TextUtils;
import android.widget.FrameLayout;

import com.bumptech.glide.Glide;
import com.github.chrisbanes.photoview.PhotoView;

import com.tongyi.lizhishop.R;
import com.tongyi.lizhishop.common.BaseActivity;
import com.tongyi.lizhishop.managers.APIServiceManager;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PhotoViewActivity extends BaseActivity {

    @BindView(R.id.photo_view)
    PhotoView photoView;
    @BindView(R.id.activity_photo_view)
    FrameLayout activityPhotoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo_view);
        ButterKnife.bind(this);
        Bundle bundle = getIntent().getExtras();
        String imageUrl = bundle.getString("imageUrl");
        Uri uri = bundle.getParcelable("uri");

        ViewCompat.setTransitionName(photoView, "shareImageView");
        if (TextUtils.isEmpty(imageUrl)) {
            Glide.with(this).load(uri).into(photoView);

        } else {

            Glide.with(this).load(APIServiceManager.server_address + imageUrl).into(photoView);
        }
    }

    @OnClick(R.id.photo_view)
    public void onViewClicked() {
        onBackPressed();
    }
}
